package com.example.demo.service.impl;

import com.example.demo.service.RedisService;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/*
 * @Author:大力王
 * @Date:2024/4/6-06-13:59
 * 开始了
 */
@Service
public class RedisServiceImple implements RedisService {
    private static final String REDIS_KEY_PREFIX_USER_TOKEN = "Redis_";

    @Resource
    private RedisTemplate<String,Object> redisTemplate;
    @Override
    public void setValue(String key, Object value) {
        redisTemplate.opsForValue().set(REDIS_KEY_PREFIX_USER_TOKEN+key,value);
    }

    @Override
    public Object getValue(String key) {
        return redisTemplate.opsForValue().get(REDIS_KEY_PREFIX_USER_TOKEN+key);
    }

    @Override
    public void deleteValue(String key) {
        redisTemplate.delete(REDIS_KEY_PREFIX_USER_TOKEN+key);
    }
}
